import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)


// 子组件值先将传入数据仓库
const screendata = {
	// 存储筛选出来的数据
	screenarr:[]
}

const searchdata = {
	// 存储搜索的数据
	searchstr:''
}

// 定位城市的值
const addressdata = {
	// 存储搜索的数据
	addressstr:''
}

// 选中小区的值
const housedata = {
	housestr:''
}

// 用户唯一标识openid
const openiddata = {
	openid:''
}

// 首页面搜索的值
const seaRchdata = {
	seaRchStr:''
}

// 数据仓库
const state = {
	screendata,
	searchdata,
	addressdata,
	housedata,
	openiddata,
	seaRchdata
}

export default new Vuex.Store({
	state,
	// 同步存储
	mutations:{
		searchmuta(state,data){
			console.log('传入数据仓库的值:' + data)
			// 存储到数据仓库中
			state.searchdata = {
				searchstr:data
			}
		},
		
		addressmuta(state,data){
			console.log('传入数据仓库的城市的值:' + data)
			// 存储到数据仓库中
			state.addressdata = {
				addressstr:data
			}
		},
		
		housemuta(state,data){
			console.log('传入数据仓库的地址值:' + data)
			// 存储到数据仓库中
			state.housedata = {
				housestr:data
			}
		},
		
		openidmuta(state,data){
			console.log('传入数据仓库的openid值:' + data)
			// 存储到数据仓库中
			state.openiddata = {
				openid:data
			}
		},
		
		seaRchmuta(state,data){
			console.log('传入数据仓库的seaRchdata值:' + data)
			// 存储到数据仓库中
			state.seaRchdata = {
				seaRchStr:data
			}
		},
	}
})